﻿using Coldairarrow.Business.Base_leasesystem_agent_img;
using Coldairarrow.Entity.Base_leasesystem_agent_img;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using NSwag.Annotations;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_leasesystem_agent_img
{
    /// <summary>
    /// 渠道证件控制器
    /// </summary>
    [Route("/Base_leasesystem_agent_img/[controller]/[action]")]
    [OpenApiTag("渠道证件控制器")]
    public class leasesystem_agent_imgController : BaseApiController
    {
        #region DI

        public leasesystem_agent_imgController(Ileasesystem_agent_imgBusiness leasesystem_agent_imgBus)
        {
            _leasesystem_agent_imgBus = leasesystem_agent_imgBus;
        }

        Ileasesystem_agent_imgBusiness _leasesystem_agent_imgBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<leasesystem_agent_img>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _leasesystem_agent_imgBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<leasesystem_agent_img> GetTheData(IdInputDTO input)
        {
            return await _leasesystem_agent_imgBus.GetTheDataAsync(input.id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(leasesystem_agent_img data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _leasesystem_agent_imgBus.AddDataAsync(data);
            }
            else
            {
                await _leasesystem_agent_imgBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        [ApiPermission("agent_img.Delete")]
        public async Task DeleteData(List<string> ids)
        {
            await _leasesystem_agent_imgBus.DeleteDataAsync(ids);
        }

        #endregion
    }
}